import request from '/@/utils/request';

// 获取oss配置

export const getSsoUrl = (data?: object)=>{
	return request({
		url: '/common/uploadKey',
		method: 'post',
		data,
	});
}

//---- 用户管理 -----
// 获取系统设置
export const fetchSettingDetail =  (params?: object) => {
	return request({
		url: '/sys/config',
		method: 'get',
		params,
	});
}

// 更新系统设置
export const fetchUpdateSetting = (data:any) => {
	return request({
		url: '/sys/config/update',
		method: 'post',
		data,
	});
};

// 账号管理

// 列表
export const fetchAccountList =  (data?: object) => {
	return request({
		url: '/sys/user/page',
		method: 'post',
		data,
	});
}

export const fetchAccountDetail =  (params?: object) => {
	return request({
		url: '/sys/user/getById',
		method: 'get',
		params,
	});
}

// 添加
export const fetchCreateAccount = (data:any) => {
	return request({
		url: '/sys/user/create',
		method: 'post',
		data,
	});
};



// 编辑
export const fetchUpdateAccount = (data:any) => {
	return request({
		url: '/sys/user/update',
		method: 'post',
		data,
	});
};

// 删除
export const fetchDelAccount = (data:any) => {
  return request({
		url: `/sys/user/delete/${data.id}`,
		method: 'delete',
		data,
	});
}

// 状态
export const fetchAccountStatus = (data:any) => {
  return request({
		url: '/sys/user/status',
		method: 'post',
		data,
	});
}

// 重置密码
export const fetchResetPwd = (data:any) => {
  return request({
		url: '/sys/user/resetPwd',
		method: 'post',
		data,
	});
}

// 修改密码
export const fetchUpdatePwd = (data:any) => {
  return request({
		url: '/sys/user/updatePwd',
		method: 'post',
		data,
	});
}


// 获取角色权限
export const fetchPermissionByRoleIds = (data:any) => {
  return request({
		url: '/sys/role/getPermissionsByRoleIds',
		method: 'post',
		data,
	});
}


// 角色权限
// 列表
export const fetchRoleList =  (data?: object) => {
	return request({
		url: '/sys/role/page',
		method: 'post',
		data,
	});
}
// 角色下拉列表
export const fetchSelectRoleList =  (params?: object) => {
	return request({
		url: '/sys/role/getSelectList',
		method: 'get',
		params,
	});
}


// 创建角色
export const fetchAddRole =  (data?: object) => {
	return request({
		url: '/sys/role/create',
		method: 'post',
		data,
	});
}

// 更新角色
export const fetchUpdateRole =  (data?: object) => {
	return request({
		url: '/sys/role/update',
		method: 'post',
		data,
	});
}

// 角色详情
export const fetchRoleDetail =  (params:any) => {
	return request({
		url: '/sys/role/getById',
		method: 'get',
		params
	});
}

// 获取权限列表
export const fetchRoleData =  () => {
	return request({
		url: '/sys/permission/loadTreeifyPermissions',
		method: 'get',
	});
}


// 获取权限列表
export const fetchDelRole =  ({id}:any) => {
	return request({
		url: `/sys/role/delete/${id}`,
		method: 'delete',
	});
}

// 服务协议
export const fetchAgreement =  (params:any) => {
	return request({
		url: '/sys/protocol',
		method: 'get',
		params
	});

}
// 协议详情
export const fetchAgreementDetail =  (params:any) => {
	return request({
		url: '/sys/protocol/detail',
		method: 'get',
		params
	});

}

// 更新协议
export const fetchUpdateAgreement =  (data:any) => {
	return request({
		url: '/sys/protocol/update',
		method: 'post',
		data
	});
}

// 操作记录
export const fetchLogList =  (data:any) => {
	return request({
		url: '/sys/oper/log/page',
		method: 'post',
		data
	});
}

// 操作记录
export const fetchLogExport =  (data:any) => {
	return request({
		url: '/sys/oper/log/export',
		method: 'post',
		responseType: 'blob',
		data
	});
}

// 价值管理
// 列表
export const fetchWorthList =  (data:any) => {
	return request({
		url: '/sys/value/page',
		method: 'post',
		data
	});
}

// 导入
export const fetchImportWorth =  (data:any) => {
	return request({
		url: '/sys/value/import',
		method: 'post',
		headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
		data
	});
}

// 新增
export const fetchCreateWorth =  (data:any) => {
	return request({
		url: '/sys/value/create',
		method: 'post',
		data
	});
}

// 详情
export const fetchWorthDetail =  (params:any) => {
	return request({
		url: '/sys/value/details',
		method: 'get',
		params
	});
}

// 编辑
export const fetchUpdateWorth =  (data:any) => {
	return request({
		url: '/sys/value/update',
		method: 'post',
		data
	});
}

// 删除
export const fetchDelWorth =  (params:any) => {
	return request({
		url: '/sys/value/delete',
		method: 'get',
		params
	});
}


// 模板
export const fetchDownWorthTemp = (params:any) => {
	return request({
		url: '/template/价值管理导入模板.xlsx',
		method: 'get',
		responseType: 'blob',
		params,
	});
};

// 系统通知
export const fetchNoticeList =  (data:any) => {
	return request({
		url: '/sys/notification/page',
		method: 'post',
		data
	});
}

// 设为已读
export const fetchNoticeRead =  (params:any) => {
	return request({
		url: '/sys/notification/read',
		method: 'get',
		params
	});
}

// 全部设为已读
export const fetchNoticeReadAll =  (params:any) => {
	return request({
		url: '/sys/notification/readAll',
		method: 'get',
		params
	});
}

// 查询是否有未读通知
export const fetchHasNotice =  (data:any) => {
	return request({
		url: '/sys/notification/checkIfUnread',
		method: 'post',
		data
	});
}
